﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace EntityDA
{
    public class NhaXuatBanDB
    {

        public NhaXuatBanData GetOneNXB(int MaNXB)
        {
            ConnectionDB cn = new ConnectionDB();
            string sql = "";
            if (MaNXB == -1)
            {
                sql = "select * from NhaXuatBan";
            }
            else
            {
                sql = "select * from NhaXuatBan where MaNXB=@MaNXB";
                cn.cmd.Parameters.Add(new SqlParameter("@MaNXB", MaNXB));
            }
            cn.cmd.CommandText = sql;
            SqlDataReader reader = cn.cmd.ExecuteReader();
            NhaXuatBanData NXB = null;
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    NXB = new NhaXuatBanData();
                    if (!reader.IsDBNull(0))
                        NXB.MaNXB = reader.GetInt32(0);
                    if (!reader.IsDBNull(1))
                        NXB.TenNXB = reader.GetString(1);
                }
            }
            return NXB;
        }
    }
}